package zhangzhongyuan.zuoye3;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@Slf4j
@RestController
@RequestMapping("/user")
public class userController {
    @Autowired
    private userService userService;

    @GetMapping("/{id}")
    public result getUserList(@PathVariable Integer id ) {
        return result.success(userService.userList(id));
    }

    @PostMapping
    public result insertUser(@RequestBody User user) {
        userService.userInsert(user);
        return result.success();
    }

    @DeleteMapping("/{id}")
    public result deleteUser(@PathVariable Integer id) {
        userService.userDelete(id);
        return result.success();
    }

    @PutMapping("/{id}")
    public result updateUser(@PathVariable Integer id, @RequestBody User user) {
        userController.log.info("传递的路径参数和数据：{}，{}", id, user);
        userService.userUpdate(id, user);
        return result.success();
    }
}